/**
 * @(#)ProcessDefinitionImageTag.java Feb 1, 2010
 *   
 * Copyright  (c) 2009-2010 Wilmar IT Service,  Inc.   
 * All  rights  reserved.   
 * TODO
 */

package com.wilmar.process.web.taglibs;

import javax.servlet.jsp.JspWriter;

import com.wilmar.process.enumerate.EnumProcessSystemTagFixedVariableNameSet;

/**
 * @author MaKuBEX Email:makubexnet@gmail.com
 * @version 1.0.0
 */
public class ProcessDefinitionImageTag extends ProcessTagSupport {

	/**
	 * @serialField
	 */
	private static final long serialVersionUID = -4836754937254072295L;

	private String alt;
	private String border;
	private String width;
	private String height;

	/**
	 * @see org.springframework.web.servlet.tags.RequestContextAwareTag#doStartTagInternal()
	 */
	protected int doStartTagInternal() throws Exception {
		StringBuffer html = new StringBuffer();
		if (super.processDefinitionId == null
				|| super.processDefinitionId.trim().length() == 0) {
			super.processDefinitionId = super
					.getAttribute(EnumProcessSystemTagFixedVariableNameSet.PROCESS_INFORMATION_PROCESS_DEFINITION_ID);
		}
		html
				.append("<img alt=\""
						+ this.alt
						+ "\" src=\"process/processDefinitionAction!doGetDefinitionImage.action?processInformation.processDefinitionId="
						+ super.processDefinitionId + "\"");
		super.appendAttribute(html, "width", this.width, null);
		super.appendAttribute(html, "height", this.height, null);
		super.appendAttribute(html, "border", this.border, null);
		html.append(">");
		JspWriter out = super.getOut();
		out.write(html.toString());
		return SKIP_BODY;
	}

	/**
	 * @return the alt
	 */
	public String getAlt() {
		return alt;
	}

	/**
	 * @param alt
	 *            the alt to set
	 */
	public void setAlt(String alt) {
		this.alt = alt;
	}

	/**
	 * @return the border
	 */
	public String getBorder() {
		return border;
	}

	/**
	 * @param border
	 *            the border to set
	 */
	public void setBorder(String border) {
		this.border = border;
	}

	/**
	 * @return the width
	 */
	public String getWidth() {
		return width;
	}

	/**
	 * @param width
	 *            the width to set
	 */
	public void setWidth(String width) {
		this.width = width;
	}

	/**
	 * @return the height
	 */
	public String getHeight() {
		return height;
	}

	/**
	 * @param height
	 *            the height to set
	 */
	public void setHeight(String height) {
		this.height = height;
	}

}
